<?php

Route::group(['middleware' => ['admin'], 'prefix' => 'admin'], function () {
    Route::controller('auth', 'Auth\AuthController');
    Route::controller('fileupload', 'UEditor\FileUploadController');

   

    Route::group(['middleware' => ['admin.auth', 'admin.rbac']], function () {
        Route::controller('migrate', 'MigrateController');
        Route::get('/', 'HomeController@index');

        Route::group(['namespace' => 'Rbac', 'prefix' => 'rbac'], function () {
            Route::resource('users', 'UsersController');
            Route::resource('roles', 'RolesController');
            Route::get('roles/{id}/permission', 'RolesController@permission');
            Route::post('roles/{id}/savePermission', 'RolesController@savePermission');
            Route::resource('permissions', 'PermissionsController');
        });

        Route::group(['namespace' => 'Web', 'prefix' => 'web'], function () {
            Route::resource('navigations', 'NavigationsController');
            Route::resource('friendly_links', 'FriendlyLinksController');
            Route::resource('article_categories', 'ArticleCategoriesController');
            Route::resource('articles', 'ArticlesController');
            Route::get('articles/create/tag', 'ArticlesController@create_tag');
            Route::resource('messages', 'MessagesController');
            Route::get('messages/query/receivers', 'MessagesController@query_receiver');
            Route::resource('informations', 'InformationsController');
            Route::resource('ads', 'AdsController');
            Route::post('message/clear_message_status', 'MessagesController@clear_message_status');
            Route::resource('profits', 'ProfitsController');
            Route::get('profits/disable/{id}', 'ProfitsController@disable');
            Route::get('fico/giftRecords', 'FicoController@giftRecords');
            Route::get('fico/giftRecords/{download?}', 'FicoController@giftRecords');
            Route::get('fico/{download?}','FicoController@index');
            Route::get('fico/checkTrade/{id}','FicoController@checkTrade');
            
            Route::get('coo/sale','CooController@index');
            Route::get('coo/sale/getdeptcode/{code}','CooController@getDeptCode');
            Route::get('coo/statistic','CooController@cooStatistic');
            Route::get('coo/user_invest_info/{download?}','CooController@userInvestInfo');
            Route::get('coo/user_invest_count/{download?}','CooController@userInvestCount');

        });


        Route::group(['namespace' => 'System', 'prefix' => 'system'], function () {
            Route::resource('code_types', 'CodeTypesController');
            Route::resource('code_types/{type_id}/codes', 'CodesController');
        });

        Route::group(['namespace' => 'Business', 'prefix' => 'business'], function () {
            Route::resource('project_type_template','ProjectTypeTemplateController');
            Route::resource('project_type_template/{project_type_template_id}/attributes','ProjectTypeTemplateAttributesController');
            Route::get('repayment','RepaymentManagementController@index');
            Route::get('repayment/{time}/{id}/query','RepaymentManagementController@repaymentInfo');
            /* users start */
            Route::resource('users','UsersController');
            Route::get('users/download/{download?}','UsersController@index');
            Route::get('users/admin/modifyPassword', 'UsersController@modifyAdminPassword');
            Route::post('users/admin/modifyPassword/save', 'UsersController@saveAdminPassword');
            Route::get('users/sina/{id}/set_real_name/','UsersController@setRealName');
            Route::post('users/sina/{id}/set_real_name/create','UsersController@saveRealName');
            Route::get('users/{id}/modify_phone_number','UsersController@modifyPhoneNumber');
            Route::get('users/1/change_broker','UsersController@changeBroker');
            Route::post('users/1/savechange_broker/{id?}','UsersController@saveChangeBroker');
            Route::post('users/1/unlock/{id?}','UsersController@unlock');
            Route::get('users/1/dept','UsersController@orgDept');
            /* end users */

            /*organizational_user_manager_start*/
            Route::resource('organizational_user_manager','OrganizationalUserManagementController');
            Route::get('organizational_user_manager/{id}/updateUserInfo','OrganizationalUserManagementController@orgToUser');
            Route::get('organizational_user_manager/{id}/broker_income_distribution','OrganizationalUserManagementController@brokerDncomeDistribution');
            Route::post('organizational_user_manager/{id}/saveBrokerDncomeDistribution','OrganizationalUserManagementController@saveBrokerDncomeDistribution');
            Route::get('organizational_user_manager/{id}/dept','OrganizationalUserManagementController@deptList');
            Route::get('organizational_user_manager/{id}/set_pay_password','OrganizationalUserManagementController@setPayPassword');
            Route::get('organizational_user_manager/{id}/set_agent_info','OrganizationalUserManagementController@setAgentInfo');
            Route::post('organizational_user_manager/{id}/save_agent_info','OrganizationalUserManagementController@saveAgentInfo');
            Route::get('organizational_user_manager/{id}/query_member_infos','OrganizationalUserManagementController@queryMemberInfos');
            Route::get('organizational_user_manager/{id}/dept/create','OrganizationalUserManagementController@createDept');
            Route::post('organizational_user_manager/{id}/dept/store','OrganizationalUserManagementController@storeDept');
            Route::get('organizational_user_manager/{id}/{dept_code}/agentList','OrganizationalUserManagementController@agentList');
            Route::get('organizational_user_manager/{id}/{dept_code}/addAgent','OrganizationalUserManagementController@addAgent');
            Route::post('organizational_user_manager/{id}/{dept_code}/userToAgent','OrganizationalUserManagementController@userToAgent');
            Route::get('organizational_user_manager/{id}/{dept_code}/{jjr_id}/removeAgent','OrganizationalUserManagementController@removeAgent');
            Route::post('organizational_user_manager/{id}/{dept_code}/{jjr_id}/agentToUser','OrganizationalUserManagementController@agentToUser');
            Route::get('organizational_user_manager/{id}/{dept_code}/{jjr_id}/changeOrganizational','OrganizationalUserManagementController@changeOrganizational');
            Route::post('organizational_user_manager/{id}/{dept_code}/{jjr_id}/saveChangeOrganizational','OrganizationalUserManagementController@saveChangeOrganizational');
            Route::get('organizational_user_manager/{id}/{dept_code}/{broker_id}/userList','OrganizationalUserManagementController@userList');
            Route::post('organizational_user_manager/{id}/{dept_code}/{broker_id}/{user_id}/saveChangeAgent','OrganizationalUserManagementController@saveChangeAgent');
            Route::get('organizational_user_manager/{id}/{dept_code}/{broker_id}/{user_id}/changeAgent','OrganizationalUserManagementController@changeAgent');
            /*end organizational_user*/

            /*销售统计 start*/
            Route::get('sales_statistics', 'SalesStatisticsController@index');
            Route::get('sales_statistics/broker_list', 'SalesStatisticsController@brokerList');
            Route::get('sales_statistics/broker_list/{id}', 'SalesStatisticsController@brokerInfo');
            Route::get('sales_statistics/user_list', 'SalesStatisticsController@userList');
            Route::get('sales_statistics/user_list/{id}', 'SalesStatisticsController@userInfo');
            Route::get('sales_statistics/transaction_record/{id}', 'SalesStatisticsController@transactionRecord');
            Route::get('sales_statistics/broker_to_user/{id}', 'SalesStatisticsController@brokerToUser');
            Route::get('sales_statistics/user_to_agent/{id}', 'SalesStatisticsController@userToAgent');
            Route::post('sales_statistics/agent_to_user/save', 'SalesStatisticsController@brokerToUserSave');
            Route::post('sales_statistics/user_to_agent/save', 'SalesStatisticsController@userToAgentSave');
            Route::get('sales_statistics/home/{download?}', 'SalesStatisticsController@salesStatistics');
            /*销售统计 end*/
            /*机构销售统计 start*/
            Route::get('org_list/{download?}','OrganizationalManagerController@orgList');
            Route::get('dept_list/{download?}','OrganizationalManagerController@deptList');
            Route::get('broker_list/{download?}','OrganizationalManagerController@brokerList');
            Route::get('user_list/{download?}','OrganizationalManagerController@userList');
            Route::get('user_info/{id}','OrganizationalManagerController@userInfo');
            /*机构销售统计 end*/

            Route::resource('demand', 'DemandController');
            Route::get('cate', 'DemandController@cate');
            Route::get('edit_project/file/{id}', 'DemandController@editProjectFile');
            Route::post('save_project/file/{id}', 'DemandController@saveProjectFile');
            Route::get('create/{id}', 'DemandController@create');
            Route::get('edit/{id}', 'DemandController@edit');
            Route::get('copy/{id}', 'DemandController@copy');
            Route::post('check1/{id}', 'DemandController@check1');
            Route::post('check2/{id}', 'DemandController@check2');
            Route::post('cancel/{id}', 'DemandController@cancel');
            Route::post('getProfitRoles', 'DemandController@getProfitRoles');
            Route::post('getUserInfo', 'DemandController@getUserInfo');
            Route::get('profit/{id}','DemandController@profit');
            Route::get('investment/{id}', 'DemandController@investment');
            Route::get('down/{id}', 'DemandController@down');
            Route::get('demand/{id}/trades', 'DemandController@trades');
            Route::get('demand/checkTrade/{id}', 'DemandController@checkTrade');
        });

        Route::group(['namespace' => 'Gift', 'prefix' => 'gift'],function(){
            Route::resource('activity', 'ActivityController');
            Route::get('activity/start/{id}', 'ActivityController@start');
            Route::post('activity/getRule', 'ActivityController@getRule');
            Route::get('activity/showRule/{id}', 'ActivityController@showRule');
            Route::get('receive', 'ActivityController@receive');
            Route::post('send', 'ActivityController@send');
            Route::get('activity/{activity}/record','RecordController@index');
            Route::get('activity/{activity}/record/{id}','RecordController@show');
        });
    });
});

    //新浪支付异步通知统一入口
Route::group(['prefix' => 'sina_pay/in'], function () {
    Route::get('/',function(){
        return 'dd';    
    });
    Route::post('corporate_membership_audit','Business\OrganizationalUserManagementController@sinapay');
});